package com.autodesk.akn.emr.dao;

import javax.sql.DataSource;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.support.JdbcDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
public class StoreDaoMySQL extends JdbcDaoSupport{
    private final static Logger LOGGER = Logger.getLogger(StoreDaoMySQL.class.getName());
	
    @Autowired
    public StoreDaoMySQL(DataSource datasource){
		setDataSource(datasource);
	}
	
	public void storeDataByFile (String filePath, String tableName) {
		try {
			String sql = "LOAD DATA LOCAL INFILE '"+filePath+"' INTO TABLE "+tableName+"2";
			getJdbcTemplate().execute(sql);
		} catch (Exception e) {
			LOGGER.error("Error storing data" + e.getMessage());
		}
	}
}
